package com.cjl.demo.thread;

/**
 * <p>Copyright: All Rights Reserved</p>
 * <p>Description: </p>
 *
 * @ uthor chenjinliang
 * @ date: 2018/12/3
 */

public class MyThread extends Thread {
    private Integer userid;
    public MyThread(Integer userid){

        System.out.println("------" + "构造函数开始" + "------ userid = " + userid);
        System.out.println("Thread.currentThread().getName() = " + Thread.currentThread().getName());
//        System.out.println("Thread.currentThread().isAlive() = " + Thread.currentThread().isAlive());
//        System.out.println("this.getName() = " + this.getName());
//        System.out.println("this.isAlive() = " + this.isAlive());
//        System.out.println("------" + "构造函数结束" + "------");

    }

    @Override
    public void run(){

        Thread testThread = Thread.currentThread();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("------" + "run()开始" + "------ userid = " +userid);
        System.out.println("Thread.currentThread().getName() = " + Thread.currentThread().getName());
//        System.out.println("Thread.currentThread().isAlive() = " + Thread.currentThread().isAlive());
//        System.out.println("this.getName() = " + this.getName());
//        System.out.println("this.isAlive() = " + this.isAlive());
//        System.out.println("Thread.currentThread() == this : " + (Thread.currentThread() == this));
//        System.out.println("------" + "run()结束" + "------");

    }


    public static void main(String[] args){

        MyThread myThread = new MyThread(1);
        myThread.setName("A");
        myThread.start();

    }

}
